﻿using UniRx;
using UnityEngine;

public class PlayerLevelComp : LevelCompAbs
{
    protected override float GetExperienceToLevelUp()
    {
        return level * 100;
    }


    private CompositeDisposable disposables = new CompositeDisposable();


    private void Start()
    {
        // 监听等级变化 打印日志
        RxEventBus.Subscribe<LevelChangeEvent>()
            .Subscribe(e => Debug.Log("等级变化 " + e.oldValue + " -> " + e.newValue))
            .AddTo(disposables); // 自动管理订阅生命周期
    }


    private void OnDestroy()
    {
        // 释放所有订阅
        disposables.Dispose();
    }
}